<!-- 菜单悬浮的原理: 通过给菜单添加position:sticky实现, 用法超简单, 仅APP端的低端机不兼容 https://caniuse.com/#feat=css-sticky -->
<template>
	<view>
		<view class="header">
			<view class="header-user" @click="toLogon">
				<view class="user-logo">
					<image class="img-full" src="@/static/user/logo.png"></image>
				</view>
				<view class="user-info">
					<view class="user-name">
						{{userinfo.nickname}}
					</view>
					<view class="user-phone">
						{{userinfo.mobile}}
					</view>
				</view>
			</view>
		</view>
		<view class="user-menu">
			<view class="user-menu-grouping" v-for="(item, i) in menus" :key="i">
				<view class="user-menu-item" @click="clickMenu(menu)" v-for="menu in item" :key="menu.key">
					<view class="user-menu-left">
						<view class="user-icon">
							<image class="img-full" :src="menu.icon"></image>
						</view>
						<view class="user-name">
							{{menu.name}}
						</view>
					</view>
					<view class="user-menu-right">
						<view class="user-arrow">
							<image class="img-full" src="@/static/home/arrow-right.png"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 此处可以写其他fixed定位元素 -->
		<!-- <view></view> -->
						<!-- :current="3" -->
		<uni-tabbar-custom :current="1"></uni-tabbar-custom>
	</view>
</template>

<script>
	
	
	export default {
		
		data() {
			return {
				menus: [
					[
						{
							icon: require('@/static/user/menu1.png'),
							name: '账号管理',
							key: 1.1
						}
						,{
							icon: require('@/static/user/menu2.png'),
							name: '意见反馈',
							key: 1.2
						},{
							icon: require('@/static/user/menu3.png'),
							name: '隐私政策',
							key: 1.3
						},{
							icon: require('@/static/user/menu4.png'),
							name: '用户协议',
							key: 1.4
						},{
							icon: require('@/static/user/menu5.png'),
							name: '使用指南',
							key: 1.5
						},{
							icon: require('@/static/user/menu6.png'),
							name: '系统设置',
							key: 1.6
						}
					],[
						{
							icon: require('@/static/user/menu7.png'),
							name: '版本说明',
							key: 2.1
						}
					]
				],
				userinfo:{
					username:'',
					mobile:''
				}
			}
		},
		onLoad(e) {
			uni.hideTabBar({});
		},
		onShow(){
			// this.$request({
			// 	url: this.$api.getUserInfo,
			// 	data: {},
			// 	method: 'get',
			// 	successCb: (res) => {
			// 		uni.hideLoading();
			// 		this.userinfo = {
			// 			...res.data,
			// 			mobile: res.data.mobile.slice(0,3) + '***' + res.data.mobile.slice(8,11)
			// 		};
			// 		console.log(res);
			// 	},
			// 	failCb(e) {
			// 		// uni.hideLoading();
			// 		console.log(e);
			// 		uni.showToast({
			// 			title: e.data.msg||'服务器异常',
			// 			icon: "none",
			// 			duration: 2000,
			// 		});
			// 	}
			// });
		},
		methods: {
			clickMenu(menu) {
				console.log('点击的菜单', menu)
				if(menu.key === 1.1) {
					uni.navigateTo({
						url: '/pages/user/accountManagement/accountManagement'
					});
				} else if(menu.key === 1.2) {
					uni.navigateTo({
						url: '/pages/user/feedbackSuggestions/feedbackSuggestions'
					});
				} else if(menu.key === 1.3) {
					uni.navigateTo({
						url: '/pages/user/privacy/privacy'
					});
				} else if(menu.key === 1.4) {
					uni.navigateTo({
						url: '/pages/user/agreement/agreement'
					});
				} else if(menu.key === 1.5) {
					uni.navigateTo({
						url: '/pages/user/guide/guide'
					});
				} else if(menu.key === 1.6) {
					uni.navigateTo({
						url: '/pages/user/setUp/setUp'
					});
				} else if(menu.key === 2.1) {
					uni.navigateTo({
						url: '/pages/user/version/version'
					});
				}
			},
			toLogon() {
				uni.navigateTo({
					url: '/pages/logon/logon/logon'
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F7F7;
	}
	.header{
		width: 750rpx;
		height: 450rpx;
		background-image: url('../../../static/user/headerBack.png');
		background-size: 100% 100%;
		padding-top: 182rpx;
		padding-left: 32rpx;
		box-sizing: border-box;
		.header-user {
			display: flex;
			align-items: center;
			.user-logo {
				width: 112rpx;
				height: 112rpx;
				border-radius: 50%;
				overflow: hidden;
			}
			.user-info {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				margin-left: 20rpx;
				.user-name {
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
					line-height: 48rpx;
				}
				.user-phone {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 48rpx;
				}
			}
		}
	}
	.user-menu {
		width: 666rpx;
		margin: 0 auto;
		transform: translateY(-158rpx);
		.user-menu-grouping {
			background: #FFFFFF;
			border-radius: 16rpx;
			padding: 0 32rpx;
			margin-top: 32rpx;
			.user-menu-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 28rpx 0;
				border-bottom: 1rpx solid #F5F5F5;
				.user-menu-left {
					display: flex;
					align-items: center;
					.user-icon {
						width: 48rpx;
						height: 48rpx;
					}
					.user-name {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: rgba(0,0,0,0.8);
						line-height: 0rpx;
						margin-left: 20rpx;
					}
				}
				.user-arrow {
					width: 36rpx;
					height: 48rpx;
				}
			}
		}
	}
</style>
